﻿<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<link href="<?php echo base_url()?>common/css/public.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?php echo base_url()?>common/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="<?php echo base_url()?>common/kindeditor/themes/default/default.css" />
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/layer/layer.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery.form.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery.metadata.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery.validate.messages_cn.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validate.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/additional-methods.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/jquery.Msg.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/MyJs.js"></script>
<script src="<?php echo base_url()?>common/kindeditor/kindeditor.js"></script>
<script src="<?php echo base_url()?>common/kindeditor/lang/zh_CN.js"></script>

<script type="text/javascript">
    $(function () {
        var index = parent.layer.getFrameIndex(window.name);
        $(".not").click(function () {
            parent.layer.close(index);
        });
    })
    function Success(data) {
        parent.Success(data);

    }
    $(function () {
        $.validate_website('ajax_form_child');
    });
    KindEditor.ready(function (K) {
        var editor = K.editor({
            uploadJson: '/common/kindeditor/php/upload_json.php?water=0',
            allowFileManager: true
        });
        function initimg() {
            editor.loadPlugin('image', function () {
                editor.plugin.imageDialog({
                    imageUrl: K('#url1').val(),
                    clickFn: function (url, title, width, height, border, align) {
                        K('#imgurl').val(url);
                        K('#img_tag').attr('src', url);
                        editor.hideDialog();
                    }
                });
            });
        }
        K('#img_tag').click(function () {
            initimg();
        });
        K('#imgurl').dblclick(function () {
            initimg();
        });
    });
    $(function () {       
        $('#menu_select_url').change(function () {
            $('#website_url').val($(this).val());
            $('#title').val($(this).find('option:selected').text());
            $('#menuid').val($(this).find('option:selected').attr('mark_menuid'));
        });
    });

    function Del(contents_id) {
        layer.confirm("确定删除", function () {
            $.post("/admin/website/del_website/" + contents_id, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }
</script>
<div id="dcMain" style="margin-left:0;padding-top:10px;">
    <!-- 当前位置 -->
    <div id="manager" class="mainBox" style="padding-top:0;">
       <?php if(empty($website_model)):?>
        <script type="text/javascript">
            $(function () {
                $('#website_url').val($("#menu_select_url option:first").val());
                $('#title').val($("#menu_select_url option:first").text());
                $('#menuid').val($("#menu_select_url option:first").attr('mark_menuid'));
            });
        </script>
        <?php endif;?>
        <form id="ajax_form_child" method="post" action="<?php echo site_url('admin/website/ajax_eidt_website')?>">
            <input type="hidden" value="<?php echo !empty($website_model)?$website_model->website_type:$website_type?>" id="website_type" name="website_type" />
            <input type="hidden" value="<?php echo !empty($website_model)?$website_model->website_id:$website_id?>" id="website_id" name="website_id" />
            <input type="hidden" value="<?php echo !empty($website_model)?$website_model->menuid:$menuid?>" id="menuid" name="menuid" />
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <td width="100" align="right">链接选择</td>
                    <td>
                        <select id="menu_select_url">
                        <?php foreach($menu_select_url as $menu_select_url_item):?>
                            <option <?php echo !empty($website_model) && $website_model->menuid==$menu_select_url_item[2]?'selected':''  ?> mark_menuid="<?php echo $menu_select_url_item[2]?>" value="<?php echo $menu_select_url_item[0]?>"><?php echo $menu_select_url_item[1]?></option>
                        <?php endforeach?>
                        </select> &nbsp; &nbsp; &nbsp;<input style="height:30px;width:400px;" type="text" value="<?php echo !empty($website_model)?$website_model->website_url:""?>" name="website_url" id="website_url" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">标题</td>
                    <td>
                        <input style="height:30px;width:200px;" type="text" value="<?php echo !empty($website_model)?$website_model->title:""?>" name="title" id="title" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">外语标题</td>
                    <td>
                        <input style="height:30px;width:200px;" type="text" value="<?php echo !empty($website_model)?$website_model->eng_title:""?>" name="eng_title" id="eng_title" />
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">图片</td>
                    <td style="position:relative;">
                        <img id="img_tag" src="<?php echo !empty($website_model)?$website_model->imgurl:""?>" onerror="this.src='<?php echo base_url('common')?>/images/nopic.png'" style="height:100px;width:100px;cursor:pointer;float:left;" />
                        <div style="float: left;position: absolute;bottom: 9px;left: 113px;">
                            <input type="text" id="imgurl" name="imgurl" size="40" class="inpMain" value="<?php echo !empty($website_model)?$website_model->imgurl:""?>" readonly="readonly" />
                            <a href="javascript:$.DeleteImg('img_tag','imgurl')" style="margin-left:20px;">删除</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="100" align="right">权重</td>
                    <td>
                        <input style="height:30px;width:200px;" type="hidden" value="<?php echo !empty($website_model)?$website_model->weight:$weight?>" name="weight" id="weight" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="submit" class="btn" value="<?php echo !empty($website_model)?"修改":"添加"?>" />
                        <?php if(!empty($website_model)){?>
                        <input type="button" class="btn" onclick="Del(<?php echo $website_model->website_id?>)" value="删除" />
                        <?php }?>
                        <input name="button" class="btn not" type="button" value="取消" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

